package ai.plantdata.Behavior.mode.VisitorPattern.interfaces.impl;

import ai.plantdata.Behavior.mode.VisitorPattern.interfaces.ComputerPart;
import ai.plantdata.Behavior.mode.VisitorPattern.interfaces.ComputerPartVisitor;

/**
 * @Author: WangHui
 * @Date: 2020/12/24 15:00
 * @Description:
 */
public class Computer implements ComputerPart {
    public ComputerPart[] parts;

    public Computer() {
        parts = new ComputerPart[] {new Mouse(), new Keyboard(), new Monitor()};
    }

    @Override
    public void accept(ComputerPartVisitor computerPartVisitor) {
        for (int i = 0; i < parts.length; i++) {
            parts[i].accept(computerPartVisitor);
        }
        computerPartVisitor.visit(this);
    }
}
